home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Utilities / mac-shell-05b / MacShell / MacShell.rsrc / help_18702_macshell < prev    next >
Encoding:
Text File  |  1994-11-23  |  10.4 KB  |  195 lines

  1. MACSHELL - GENERAL INFORMATION 
  2.  
  3. MacShell is a Unix-like command line interface for the Macintosh.  It performs a limited impersonation of the Unix C shell, and contains abbreviated versions of a set of Unix style file management, file finding, and content searching utilities.  It also does a few Macintosh-specific functions, is scriptable, and has a no-frills text editor built-in.
  4.  
  5. MacShell is free, courtesy of Fred Videon.  It may not be sold in any form.
  6.  
  7. THE SHELL
  8.  
  9. The "Shell" component of the program has the following capabilities:
  10. -Executes a set of built-in utilities.
  11. -Executes code resources from external resource files.
  12. -Performs file name substitution. (known to some as "globbing")
  13. -Handles pipes.
  14. -Performs redirection of standard I/O to and from files using the operators ">" and "<".
  15. -Manages shell variables.
  16. -Runs scripts.
  17.  
  18. Among the many "shell" functions which MacShell does not support are the following:
  19. -Flow control operators
  20. -Launching of other applications
  21. -Command history
  22. -Alias substitutions
  23. -Backquote substitution
  24.  
  25. BUILT-IN UTILITIES
  26.  
  27. This version performs approximations of the Unix utilities in the following list.
  28.  
  29. Note:  to get more help with any command, type:
  30.                 man commandname
  31.  
  32. command    description
  33. -------    -----------
  34.   man      get help
  35.   cd       change directory
  36.   pwd      print working directory
  37.   ls       list the contents of a directory
  38.   cat      concatenate (spit the input to the output)
  39.   head     copy the beginning of the input to the output
  40.   tail     copy the end of the input to the output
  41.   cp       copy files and directories
  42.   mv       move or rename files and directories
  43.   rm       remove files and directories
  44.   mkdir    make directory
  45.   grep     file content search
  46.   egrep    file content search using regular expressions
  47.   find     find a file or directory by name or attribute
  48.   more     view a file
  49.   exit     quit MacShell
  50.  
  51. Additionally MacShell approximates some utilities which are built in to the Unix C shell:
  52.  
  53.   set      set a shell variable
  54.   unset    clear, or unset a shell variable
  55.   echo     report command line arguments on the output.
  56.   source   execute a file as a script
  57.  
  58. Finally, MacShell has a few special non Unix-like functions:
  59.  
  60.   mem       show heap statistics
  61.   free      show free heap space
  62.   compact   compact heap and report largest contiguous block
  63.   seg       filter to segment long lines into shorter lines
  64.   xn        filter out null characters from a stream
  65.   chtype    change a Macintosh file type signature
  66.   chcreator change a Macintosh file creator signature
  67.   bintohex  convert input to hexidecimal notation
  68.  
  69. DETAILS OF SHELL FUNCTIONS
  70.  
  71. The following "shell" functionality is supported by MacShell:
  72.  
  73. FILE NAME SUBSTITUTION
  74.  
  75. If MacShell finds the asterisk (*) in a command argument, it will attempt to substitute any string of characters (including the null string) in place of the asterisk to form one or more valid file names.  This name (or these names) will be substituted into the command string prior to the execution of the command.  Correct case must be observed when this mechanism is used. (Otherwise the Macintosh is case-insensitive.) 
  76.  
  77. An asterisk may be hidden from MacShell by surrounding the argument that contains it in either double ("") or single ('') quotes.  The argument will then be passed on to its command unaltered.
  78.  
  79. PIPE HANDLING
  80.  
  81. MacShell allows the output of one of its commands to be directed to the input of another by means of a pipe.  The pipe character (|) is used to separate the two commands.  (Note that MacShell's internal implementation of the pipe is quite different from the Unix implementation, even though they behave very similiarly)
  82.  
  83. REDIRECTION OF COMMAND INPUT AND OUTPUT TO AND FROM FILES
  84.  
  85. MacShell supports the use of I/O redirection operators "<" and ">."   A filename which follows the input redirection symbol (<) on the command line will be opened and its contents will be used as input for the command.  A filename which follows the output redirection operator (>) will be created if it does not exist (and overwritten if it does exist), and the output of the command will be written to it.
  86.  
  87. SHELL VARIABLES
  88.  
  89. MacShell is capable of managing shell variables.  Shell variables are set and cleared with "set" and "unset." (See separate manual entries for set and unset).  Set is also useful for displaying a list of currently defined variables and their values.  
  90.  
  91. Once a shell variable is defined it's value may be used by the variable substitution mechanism to form part of a command line.  Variable substitution is triggered by a '$' immediately preceeding the variable name. Variable substitution takes place before file name substitution.  The entire variable (including the index, if used) may be surrounded by curly braces '{}' to avoid ambiguity if the name does not form a separate argument.
  92.  
  93. A shell variable may take a value of zero or more words.  If the value consists of more than one word, the individual words may be selected by means of an index value in square brackets immediately following the variable name.  The index value itself may be a shell variable since the variable substitution mechanism will evaluate index values first. Index values begin at 1.  Supplying an index value of zero generates an error.
  94.  
  95. Special designators "$#" and "$?" can be used immediatly preceeding a shell variable name to cause the substitution mechanism to insert other information about shell variables.  "$#varname" will be replaced with the number of words in the value of "varname," while "$?varname" will be replaced with "1" if the variable is set, and "0" otherwise.
  96.  
  97. SHELL VARIABLE EXAMPLES
  98.  
  99. Shell variables may be set in any of the following ways:
  100.  
  101.    set a=1
  102.    set b=abc
  103.    set c
  104.       set d=()
  105.    set e=(1 2 3)
  106.       set e[1]=4
  107.  
  108. Some simple examples using the shell utility "echo" to report the results of variable substitution with the variables defined above:
  109.  
  110.    echo $a
  111.     1
  112.    echo $e
  113.     (4 2 3)
  114.    echo $e[2]
  115.     2
  116.    echo $e[$a]
  117.     4
  118.    echo I'm${e[$a]}it
  119.     I'm4it
  120.    echo $#e
  121.     3
  122.    echo $?b
  123.     1
  124.    echo he's $?{b}for fun
  125.      he's 1for fun
  126.    echo $?z
  127.     0
  128.  
  129. SCRIPTS
  130.  
  131. MacShell includes a built-in utilitiy which will open a file and execute each line as a MacShell command.  No control flow operators are supported at this time.  (For more information see the manual entry for "source").  In addition MacShell can execute certain files at launch time.  For more information, see the headings "startup files" and "configuration file" in this entry.  
  132.  
  133. STANDARD INPUT AND STANDARD OUTPUT
  134.  
  135. Standard input and output is a means by which many Unix utilities interact with the outside world.  MacShell supports this paradigm to some extent. 
  136.  
  137. Standard input may be directed to some MacShell commands from a file with the input redirection operator (<), or from the output of the preceeding command using a pipe (|).  MacShell cannot use the interactive window as standard input at this time.
  138.  
  139. The default standard output for most MacShell commands is the interactive window.  If the pipe operator (|) is used, standard output is routed to the command which follows.  If the output redirection operator (>) is present, standard output is directed to the file whose name follows the operator.
  140.  
  141.  
  142. ABOUT MACINTOSH PATH NAMES
  143.  
  144. According to Macintosh convention, the colon (:) is used in path names to separate volume, folder and file names. The following rules should be noted: 
  145.  
  146. -Absolute path names do not begin with a colon, for example:
  147.      MyDisk:MyFolder:MyFile
  148.  
  149. -When an absolute path name consists of only one name, it must end in a colon, for example:
  150.      MyDisk:
  151.  
  152. -Relative path names must begin with a colon, except in the case where they consist of only one name:
  153.      MyFolder
  154.      :MyFolder:MyFile
  155.  
  156. -Consecutive colons may be used in a path name to represent a move up the directory tree.  Two colons (::) would represent the parent of the working directory, three would represent the parent of the parent, and so on.
  157.  
  158. CASE SENSITIVITY 
  159.  
  160. The Macintosh finder and toolbox are not case sensitive.  In other words, as far as the Macintosh is concerned, "Filename" is the same as "filename."  Therefore it is not necessary to observe case when using MacShell to interface directly with the Macintosh file system.  
  161.  
  162. However, MacShell's file name substitution function IS case sensitive.  If asterisks are used as wildcard characters in file names, case must be observed in the remainder of the name (this should be changed).
  163.  
  164. ESCAPE NAME COMPLETION
  165.  
  166. When used interactively MacShell will attempt to complete a file name when the escape key is typed.  The user must first type enough characters to form a unique beginning of a file name.  The mechanism will add characters until a  point of ambiguity is reached, or until the file name is completed.  If the file name is not completed, the mechanism will cause a system beep.
  167.  
  168. Since Macintosh file names may include embedded spaces, and since these names must be quoted in MacShell, the name completion function will ignore a quote found at the beginning of a word.  This will allow most file names with embedded spaces to be quoted and automatically completed with ease.
  169.  
  170. The wildcard character "*" is not recognized by the file name completion mechanism.
  171.  
  172. Those using older keyboards which don't have the escape key may trigger this function by first setting a special shell variable called "remapesc".  This will cause the backquote in the upper left corner of the old Mac Plus keyboard to be interpreted as the escape key. 
  173.  
  174. STARTUP FILES
  175.  
  176. MacShell treats its startup files just as most other applications do: The files are opened immediately after MacShell is launched.  However, it is also possible to cause MacShell to treat startup files as scripts to be executed.   A MacShell file will be executed on startup if the first two characters in the file are "#!".(This string is referred to as the Magic Cookie).  
  177.  
  178. Note that a file with the magic cookie will not be executed when it is opened from the File menu, or dealt with by MacShell in most other ways.
  179.  
  180. CONFIGURATION FILE
  181.  
  182. If a file called "macshell.rc" is found in the same directory with the  MacShell application itself, this file will be opened and executed as a script when MacShell is launched.
  183.  
  184. INVOKING EXTERNAL CODE RESOURCES FROM MACSHELL
  185.  
  186. It's possible to write code in a language like C or Pascal, and compile it into code resources which can be called directly by MacShell.  Let me know if you want more details.  I have some sample code (in C) demonstrating how to do this.
  187.  
  188. HOW TO CONTACT THE AUTHOR
  189.  
  190. By email:
  191.    fred@cs.washington.edu
  192.  
  193.  
  194.